Significance: Headwater streams account for a majority of river networks worldwide and have a disproportionately large influence on the functioning of aquatic ecosystems. Headwater streams also support critical habitat for many species, including cold-water fishes, many of which are declining or at risk of extinction.

Problem: Headwater streams are largely underrepresented in streamflow monitoring networks, which place greater emphasis on mainstem rivers. As a result, less is known about how headwaters respond to changing water availability. Headwater streams therefore represent a blind spot in understanding flow regime variability and assessing the vulnerability of cold-water fish to changing climatic conditions, including the increasing frequency and severity of drought.

Existential question: How do streamflow regimes vary spatially in headwater stream networks and what does this imply about the sensitivity of these systems (and the species they support) to changing climatic conditions (i.e., drought)?

Objectives: In progress…

  1. Evaluate the extent and magnitude of spatial and temporal variation in headwater streamflow.
  1. Visualize time series data to show difference in streamflow regimes between reference gages (big G/NWIS) and upstream gages (little g’s) * Back up with flow exceedance curves to describe spatial diversity in distribution of flow values, generally
  2. Use scatterplots to show how hysteresis/non-stationarity/non-linearity in g~G relationships changes among basins (rain vs. snow) and sites within basins. 2. Evaluate the suitability of existing modeling techniques for predicting streamflow in headwater systems.
  3. Use NSE (Nash-Sutcliffe efficiency) to compare the performance of regional regression, NWM/PRMS, and deep learning approaches for modeling headwater streamflow
  1. Demonstrate how drought-related low flow conditions manifest differently in streams across headwater networks.
  1. Using fixed and seasonally variable low flow/drought thresholds derived from long-term (1970-present) big G data (sensu Hammond et al. 2022), show how streamflow drought duration and deficit vary among headwater streams (relative to big G). Violin plots with points for little g’s relative to big G
  2. How does the spread of values (spatial variation in drought duration and deficit) change among years that differ in regional water availability?
  1. Explore how the spatial structure/geometry of headwater stream networks combines with regional water availability to affect within-network variation in straemflow regimes (and similarity in low flow/drought response?)
  1. Use fluvial synchronograms to explore the effects of flow connectivity, branching complexity, and regional water availability on short-scale synchrony and decay

11.1 Data

Site information and map

Code
# site information
siteinfo <- read_csv("C:/Users/jbaldock/OneDrive - DOI/Documents/USGS/EcoDrought/EcoDrought Working/Data/EcoDrought_SiteInformation.csv")
siteinfo_sp <- st_as_sf(siteinfo, coords = c("long", "lat"), crs = 4326)
mapview(siteinfo_sp, zcol = "designation")

11.1.1 Little g’s

Little g daily data

Code
# flow/yield (and temp) data 
dat <- read_csv("C:/Users/jbaldock/OneDrive - DOI/Documents/USGS/EcoDrought/EcoDrought Working/Data/EcoDrought_FlowTempData_DailyWeekly.csv") %>%
  mutate(site_name = dplyr::recode(site_name, "Leidy Creek Mouth NWIS" = "Leidy Creek Mouth", "SF Spread Creek Lower NWIS" = "SF Spread Creek Lower", "Dugout Creek NWIS" = "Dugout Creek", "Shields River ab Smith NWIS" = "Shields River Valley Ranch")) %>%
  filter(!site_name %in% c("Avery Brook NWIS", "West Brook 0", "BigCreekMiddle",                # drop co-located sites
                           "South River Conway NWIS", "North Fork Flathead River NWIS",         # drop big Gs
                           "Pacific Creek at Moran NWIS", "Shields River nr Livingston NWIS",   # drop big Gs
                           "Donner Blitzen River nr Frenchglen NWIS",                           # drop big Gs
                           "WoundedBuckCreek")) %>%                                             # drop little g outside of focal basin
  group_by(site_name, basin, subbasin, region, date) %>%
  summarize(flow_mean = mean(flow_mean),
            tempc_mean = mean(tempc_mean),
            Yield_mm = mean(Yield_mm),
            Yield_filled_mm = mean(Yield_filled_mm)) %>%
  ungroup()

# add water/climate year variables and fill missing dates
dat <- fill_missing_dates(dat, dates = date, groups = site_name)
dat <- add_date_variables(dat, dates = date, water_year_start = 10)

Clean and bind little g data (for each basin, restrict to time period for which data quality/availability is ~consistent)

Code
dat_clean <- bind_rows(
  dat %>% filter(site_name %in% unlist(siteinfo %>% filter(subbasin == "West Brook") %>% select(site_name)), year(date) >= 2020, date <= date("2025-01-03")) %>% 
    mutate(Yield_filled_mm = ifelse(site_name == "West Brook Upper" & date > date("2024-10-06"), NA, Yield_filled_mm)) %>%
    mutate(Yield_filled_mm = ifelse(site_name == "Mitchell Brook" & date > date("2021-02-28") & date < date("2021-03-26"), NA, Yield_filled_mm)) %>% 
    mutate(Yield_filled_mm = ifelse(site_name == "Mitchell Brook" & date > date("2021-11-01") & date < date("2022-05-01"), NA, Yield_filled_mm)) %>% 
    mutate(subbasin = "West Brook"),
  
  dat %>% filter(site_name %in% unlist(siteinfo %>% filter(subbasin == "Paine Run") %>% select(site_name)), date >= as_date("2018-11-07"), date <= as_date("2023-05-15")) %>% mutate(subbasin = "Paine Run"),
  
  dat %>% filter(site_name %in% unlist(siteinfo %>% filter(subbasin == "Staunton River") %>% select(site_name)), date >= as_date("2018-11-07"), date <= as_date("2022-10-19")) %>% mutate(subbasin = "Staunton River"),
  
  dat %>% filter(site_name %in% c(unlist(siteinfo %>% filter(subbasin == "Big Creek") %>% select(site_name)), "North Fork Flathead River NWIS"), date >= date("2018-08-08"), date <= date("2023-08-03"), site_name != "SkookoleelCreek", Yield_filled_mm > 0)  %>% mutate(subbasin = "Big Creek"),
  
  dat %>% filter(site_name %in% c(unlist(siteinfo %>% filter(subbasin == "Coal Creek") %>% select(site_name)), "North Fork Flathead River NWIS"), date >= date("2018-07-29"), date <= date("2023-08-03")) %>% mutate(subbasin = "Coal Creek"),
  
  dat %>% filter(site_name %in% c(unlist(siteinfo %>% filter(subbasin == "McGee Creek") %>% select(site_name)), "North Fork Flathead River NWIS"), date >= date("2017-07-30"), date <= date("2023-12-11")) %>% mutate(subbasin = "McGee Creek"),
  
  dat %>% filter(subbasin == "Snake River", date >= date("2016-04-01"), date <= date("2023-10-03"), site_name != "Leidy Creek Upper") %>% mutate(subbasin = "Snake River"),
  
  dat %>% filter(subbasin == "Shields River", date >= date("2016-04-01"), date <= date("2023-12-31"), site_name != "Brackett Creek") %>% 
  mutate(logYield = log10(Yield_filled_mm)) %>% mutate(subbasin = "Shields River"),
  
  dat %>% filter(subbasin == "Duck Creek", date >= date("2015-04-01"), date <= date("2023-12-31")) %>% mutate(subbasin = "Duck Creek"),
  
  dat %>% filter(subbasin == "Donner Blitzen", date >= as_date("2019-04-23"), date <= as_date("2022-12-31"), !site_name %in% c("Indian Creek NWIS", "Little Blizten River NWIS")) %>% mutate(subbasin = "Donner Blitzen")
) %>%
  filter(Yield_filled_mm > 0) %>%
  mutate(logYield = log10(Yield_filled_mm), 
         designation = "little", 
         doy_calendar = yday(date)) %>%
  select(-Yield_mm) %>%
  rename(Yield_mm = Yield_filled_mm)
head(dat_clean)
# A tibble: 6 × 16
  site_name   basin     subbasin region date       flow_mean tempc_mean Yield_mm
  <chr>       <chr>     <chr>    <chr>  <date>         <dbl>      <dbl>    <dbl>
1 Avery Brook West Bro… West Br… Mass   2020-01-08      5.96     0.594      1.99
2 Avery Brook West Bro… West Br… Mass   2020-01-09      4.81     0.0336     1.61
3 Avery Brook West Bro… West Br… Mass   2020-01-10      4.88     0.363      1.63
4 Avery Brook West Bro… West Br… Mass   2020-01-11      6.43     1.77       2.15
5 Avery Brook West Bro… West Br… Mass   2020-01-12     21.2      2.81       7.08
6 Avery Brook West Bro… West Br… Mass   2020-01-13     14.3      1.92       4.78
# ℹ 8 more variables: CalendarYear <dbl>, Month <dbl>, MonthName <fct>,
#   WaterYear <dbl>, DayofYear <dbl>, logYield <dbl>, designation <chr>,
#   doy_calendar <dbl>

11.1.2 Big G’s

Load big/super G data

Code
nwis_daily <- read_csv("C:/Users/jbaldock/OneDrive - DOI/Documents/USGS/EcoDrought/EcoDrought Working/Data/EcoDrought_NWIS_FlowTempData_Raw_Daily.csv") %>%
  filter(designation == "big", 
         year(date) >= 1970,
         site_name != "Shields River nr Livingston NWIS") %>%
  mutate(flowcfs = ifelse(site_name == "Rapidan River NWIS" & date > date("1995-06-26") & date < date("1995-07-01"), NA, flowcfs),
         flow_mean_cms = flowcfs*0.02831683199881, 
         area_sqkm = area_sqmi*2.58999)

# sites
sites <- unique(nwis_daily$site_name)

# site-specific basin area in square km
basinarea <- nwis_daily %>% filter(!is.na(site_id)) %>% group_by(site_name) %>% summarize(area_sqkm = unique(area_sqkm))

# calculate yield
yield_list <- list()
for (i in 1:length(sites)) {
  d <- nwis_daily %>% filter(site_name == sites[i])
  ba <- unlist(basinarea %>% filter(site_name == sites[i]) %>% select(area_sqkm))
  yield_list[[i]] <-  add_daily_yield(data = d, values = flow_mean_cms, basin_area = as.numeric(ba))
}
nwis_daily_wyield <- do.call(rbind, yield_list)

dat_clean_big <- nwis_daily_wyield %>% 
  select(site_name, basin, subbasin, region, date, Yield_mm, tempc, flowcfs) %>% 
  mutate(logYield = log10(Yield_mm), doy_calendar = yday(date)) %>%
  rename(tempc_mean = tempc, flow_mean = flowcfs)

# add water/climate year variables and fill missing dates
dat_clean_big <- fill_missing_dates(dat_clean_big, dates = date, groups = site_name)
dat_clean_big <- add_date_variables(dat_clean_big, dates = date, water_year_start = 10)

head(dat_clean_big)
# A tibble: 6 × 15
  site_name       basin subbasin region date       Yield_mm tempc_mean flow_mean
  <chr>           <chr> <chr>    <chr>  <date>        <dbl>      <dbl>     <dbl>
1 South River Co… West… West Br… Mass   1970-01-01     1.81         NA        46
2 South River Co… West… West Br… Mass   1970-01-02     1.69         NA        43
3 South River Co… West… West Br… Mass   1970-01-03     1.61         NA        41
4 South River Co… West… West Br… Mass   1970-01-04     1.53         NA        39
5 South River Co… West… West Br… Mass   1970-01-05     1.49         NA        38
6 South River Co… West… West Br… Mass   1970-01-06     1.49         NA        38
# ℹ 7 more variables: logYield <dbl>, doy_calendar <dbl>, CalendarYear <dbl>,
#   Month <dbl>, MonthName <fct>, WaterYear <dbl>, DayofYear <dbl>

View big G streamflow time series data

Code
dat_clean_big %>% ggplot() + geom_line(aes(x = date, y = logYield)) + facet_wrap(~site_name, nrow = 8) + theme_bw()

11.1.3 Climate

Download Daymet precip data and summarize by water year

Code
# big G site lat/long
mysites <- nwis_daily %>% group_by(site_name, basin, subbasin, region) %>% summarize(lat = unique(lat), long = unique(long)) %>% ungroup()

# download point location Daymet data
climlist <- vector("list", length = dim(mysites)[1])
for (i in 1:dim(mysites)[1]) {
  clim <- download_daymet(site = mysites$site_name[i], lat = mysites$lat[i], lon = mysites$long[i], start = 1980, end = 2024, internal = T)
  climlist[[i]] <- tibble(clim$data) %>% 
    mutate(air_temp_mean = (tmax..deg.c. + tmin..deg.c.)/2, 
           date = as.Date(paste(year, yday, sep = "-"), "%Y-%j"),
           site_name = mysites$site_name[i]) %>%
    select(12,2,11,10,4,6) %>% rename(precip_mmday = 5, swe_kgm2 = 6)
  print(i)
}
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
[1] 8
Code
# combine and add water years
climdf <- do.call(rbind, climlist) %>% left_join(mysites) %>% mutate(year = year(date))
climdf <- add_date_variables(climdf, dates = date, water_year_start = 10)

# calculate total annual precipitation in mm, by site and water year
climdf_summ <- climdf %>% 
  group_by(site_name, basin, subbasin, region, WaterYear) %>% 
  summarize(precip_total = sum(precip_mmday), sampsize = n()) %>% 
  mutate(precip_total_z = scale(precip_total)) %>%
  ungroup() %>% 
  filter(sampsize >= 350)

View time series and scatter plots of big G water availability (total annual yield, sum of daily values, black lines) and precipitation (total annual precip, blues lines). Note that the panel labels indicate basins, not NWIS gage names. In the manuscript, pair these plots with CONUS map and detailed inset maps of focal basins (Figure 1)

Code
# calculate annual water availability at big g as sum of daily yield values...retain only years with >95% data coverage (at least 350 days)
wateravail <- dat_clean_big %>% 
  filter(!is.na(Yield_mm)) %>%
  group_by(basin, site_name, WaterYear) %>% 
  summarize(sampsize = n(), totalyield = sum(Yield_mm, na.rm = TRUE)) %>% 
  mutate(totalyield_z = scale(totalyield)[,1]) %>%
  ungroup() %>%
  filter(sampsize >= 350) %>% 
  complete(basin, WaterYear = 1971:2024, fill = list(sampsize = NA, totalyield = NA))

# get range of years for little g data
daterange <- dat_clean %>% group_by(basin) %>% summarize(minyear = year(min(date)), maxyear = year(max(date)))

# spread ecod years
mylist <- vector("list", length = dim(daterange)[1])
for (i in 1:dim(daterange)[1]) {
  mylist[[i]] <- tibble(basin = daterange$basin[i], WaterYear = seq(from = daterange$minyear[i], to = daterange$maxyear[i], by = 1))
}
yrdf <- do.call(rbind, mylist) %>% mutate(ecodyr = "yes")
Code
ggplot() + 
  geom_rect(data = daterange, aes(xmin = minyear-0.5, xmax = maxyear+0.5, ymin = -Inf, ymax = +Inf), fill = "grey") +
  geom_line(data = wateravail, aes(x = WaterYear, y = totalyield), linewidth = 1) + 
  geom_line(data = climdf_summ, aes(x = WaterYear, y = precip_total), linewidth = 0.5, col = "blue") +
  facet_wrap(~basin) + 
  xlab("Water year") + ylab("Total annual yield (mm) / Total annual precipitation (mm)") +
  theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

Code
ggplot() + 
  geom_rect(data = daterange, aes(xmin = minyear-0.5, xmax = maxyear+0.5, ymin = -Inf, ymax = +Inf), fill = "grey") +
  geom_line(data = wateravail, aes(x = WaterYear, y = totalyield_z), linewidth = 1) + 
  geom_line(data = climdf_summ, aes(x = WaterYear, y = precip_total_z), linewidth = 0.5, col = "blue") +
  facet_wrap(~basin) + 
  xlab("Water year") + ylab("Total annual yield (scaled) / Total annual precipitation (scaled)") +
  theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

Code
wateravail %>% select(-sampsize) %>% left_join(climdf_summ %>% select(-sampsize)) %>% left_join(yrdf) %>%
  ggplot(aes(x = precip_total_z, y = totalyield_z)) +
  geom_point(aes(color = ecodyr)) +
  facet_wrap(~basin) + 
  xlab("Total annual precipitation (scaled)") + ylab("Total annual yield (scaled)") +
  theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none") +
  stat_cor(method = "pearson", aes(label = ..r.label..))

11.2 Objective 1

Objective 1: Evaluate the extent and magnitude of spatial and temporal variation in headwater streamflow.

Approach:

  • Visualize time series data to show difference in streamflow regimes between reference gages (big G/NWIS) and upstream gages (little g’s)
  • Back up with flow exceedance curves to describe spatial diversity in distribution of flow values, generally

Notes:

  • Consider combining subbasins
    • Flathead = Coal, Big, and McGee Creeks
    • Yellowstone = Shields River and Duck Creek
    • Shenandoah??? Hard b/c Staunton, Paine, and Piney all use different big G’s
  • Might be helpful to plot panels of static time series plot on the same x-axis/time scale
  • Not sure how necessary ridgeline plots are under the current framework/objectives, although they do highlight differences in variability between big and littls g’s
  • Exceedance curves need updating/doing, perhaps facet by year and restrict to summer/low flow season only (July, August, September).

11.2.1 Spaghetti plots

View daily time series data by sub-basin. Note that we are using the “Super G” NWIS data for the reference gage (black line). Per Robert comment, entirely nested design is cute, but doesn’t reflect how the data is actually used.

Big G NWIS sites/reference gages for each basin/subbasin:

Code
dat_clean_big %>% group_by(region, basin, subbasin) %>% summarize(site_name = unique(site_name)) %>% ungroup() %>% filter(!is.na(region)) %>% kable()
region basin subbasin site_name
Flat Flathead Flathead North Fork Flathead River NWIS
Mass West Brook West Brook South River Conway NWIS
Oreg Donner Blitzen Donner Blitzen Donner Blitzen River nr Frenchglen NWIS
Shen Paine Run Paine Run South River Harriston NWIS
Shen Piney River Piney River Battle Run NWIS
Shen Staunton River Staunton River Rapidan River NWIS
Shields Shields River Shields River Yellowstone River Livingston NWIS
Snake Snake River Snake River Pacific Creek at Moran NWIS

11.2.1.1 Interactive

11.2.1.2 Static

Plotting function

Code
# set up color palette
mycols <- c(brewer.pal(8, "Dark2"), "dodgerblue", "darkorchid")

# create plotting function
myplotfun <- function(subbas, lab, bigG) {
  data_sub <- dat_clean %>% filter(subbasin == subbas)
  par(mar = c(1.7,1.7,0.1,0.1), mgp = c(2.5,0.6,0))
  plot(logYield ~ date, data_sub, type = "n", xlab = "", ylab = "")
  #tempdat_little <- data_sub %>% filter(designation == "little")
  tempdat_little <- fill_missing_dates(data_sub, dates = date, groups = site_name, pad_ends = FALSE)
  tempdat_big <- dat_clean_big %>% filter(site_name == bigG, date >= min(tempdat_little$date), date <= max(tempdat_little$date))
  #tempdat_big <- data_sub %>% filter(designation == "big")
  tempdat_big <- fill_missing_dates(tempdat_big, dates = date, groups = site_name, pad_ends = FALSE)
  mysites <- sort(unique(tempdat_little$site_name))
  for (i in 1:length(mysites)) {
    lines(logYield ~ date, tempdat_little %>% filter(site_name == mysites[i]), col = mycols[i], lwd = 0.7)
    }
  lines(logYield ~ date, tempdat_big, col = "white", lwd = 1.7)
  lines(logYield ~ date, tempdat_big, col = "black", lwd = 1)
  usr <- par("usr")
  par(usr = c(0,1,0,1))
  text(0.02, 0.9, labels = lab, cex = 1.2)
  par(usr = usr)
}

Generate plot

Code
jpeg("C:/Users/jbaldock/OneDrive - DOI/Documents/USGS/EcoDrought/EcoDrought Working/EcoDrought-Analysis/Qualitative/EcoD_timeseries.jpg", width = 8, height = 12, units = "in", res = 1000)

par(mfrow = c(10,1), oma = c(0.5,2,0.5,0.5))

# West Brook
myplotfun(subbas = "West Brook", lab = "(a)", bigG = "South River Conway NWIS")

# Paine
myplotfun(subbas = "Paine Run", lab = "(b)", bigG = "South River Harriston NWIS")

# Staunton River
myplotfun(subbas = "Staunton River", lab = "(c)", bigG = "Rapidan River NWIS")

# Big Creek
myplotfun(subbas = "Big Creek", lab = "(d)", bigG = "North Fork Flathead River NWIS")

# Coal Creek
myplotfun(subbas = "Coal Creek", lab = "(e)", bigG = "North Fork Flathead River NWIS")

# McGee Creek
myplotfun(subbas = "McGee Creek", lab = "(f)", bigG = "North Fork Flathead River NWIS")

# Snake River
myplotfun(subbas = "Snake River", lab = "(g)", bigG = "Pacific Creek at Moran NWIS")

# Shields River
myplotfun(subbas = "Shields River", lab = "(h)", bigG = "Yellowstone River Livingston NWIS")

# Duck Creek
myplotfun(subbas = "Duck Creek", lab = "(i)", bigG = "Yellowstone River Livingston NWIS")

# Donner Blitzen
myplotfun(subbas = "Donner Blitzen", lab = "(j)", bigG = "Donner Blitzen River nr Frenchglen NWIS")

# common axis label
mtext("log(Daily yield, mm)", outer = TRUE, side = 2, line = 0.5)

dev.off()
png 
  2 

Observed daily streamflow in yield (mm) in 10 headwater basins of North America.

11.2.2 Exceedance curves

these all should probably be trimmed to just the summer data…or comparable period over which data availability is maximized across sites and subbasins

Need to do

Plotting functions

Code
# create plotting function
myplotfun_ex <- function(subbas, lab) {
  # filter to subbasin and get site designation
  data_sub <- dat_clean %>% filter(subbasin == subbas, Month %in% c(7,8,9))
  sitesdesig <- data_sub %>% group_by(site_name) %>% summarize(designation = unique(designation)) %>% ungroup()
  # calculate exceedance probability by site
  exeeddat <- data_sub %>% 
    select(date, site_name, logYield) %>%
    spread(key = site_name, value = logYield) %>% 
    drop_na() %>%
    gather(key = site_name, value = logYield, 2:ncol(.)) %>%
    group_by(site_name) %>%
    arrange(desc(logYield), .by_group = TRUE) %>%
    mutate(exceedance = 100/length(logYield)*1:length(logYield)) %>%
    ungroup() %>%
    left_join(sitesdesig)
  exeeddat_little <- exeeddat %>% filter(designation == "little")
  exeeddat_big <- exeeddat %>% filter(designation == "big")
  # set up plot
  par(mar = c(1.7,1.7,0.1,0.1), mgp = c(2.5,0.6,0))
  mysites <- sort(unique(exeeddat_little$site_name))
  plot(logYield ~ exceedance, exeeddat, type = "n", xlab = "", ylab = "")
  # add little g's
  for (i in 1:length(mysites)) {
    lines(logYield ~ exceedance, exeeddat_little %>% filter(site_name == mysites[i]), col = mycols[i], lwd = 1)
  }
  # add big G
  lines(logYield ~ exceedance, exeeddat_big, col = "white", lwd = 2.7)
  lines(logYield ~ exceedance, exeeddat_big, col = "black", lwd = 2)
  # panel label
  usr <- par("usr")
  par(usr = c(0,1,0,1))
  text(0.92, 0.9, labels = lab, cex = 1.2)
  par(usr = usr)
}  


# CV of little g Yield by exceedance probability
myplotfun_cv <- function(subbas, lab) {
  # filter to subbasin and get site designation
  data_sub <- dat_clean %>% filter(subbasin == subbas)
  sitesdesig <- data_sub %>% group_by(site_name) %>% summarize(designation = unique(designation)) %>% ungroup()
  # calculate exceedance probability by site
  exeeddat <- data_sub %>% 
    select(date, site_name, logYield) %>%
    spread(key = site_name, value = logYield) %>% 
    drop_na() %>%
    gather(key = site_name, value = logYield, 2:ncol(.)) %>%
    group_by(site_name) %>%
    arrange(desc(logYield), .by_group = TRUE) %>%
    mutate(exceedance = 100/length(logYield)*1:length(logYield)) %>%
    ungroup() %>%
    left_join(sitesdesig)
  exeeddat_little <- exeeddat %>% filter(designation == "little")
  exeeddat_big <- exeeddat %>% filter(designation == "big")
  # set up plot
  par(mar = c(1.7,1.7,0.1,0.1), mgp = c(2.5,0.6,0))
  mysites <- sort(unique(exeeddat_little$site_name))
  tiblist <- list()
  for (i in 1:length(mysites)) {
    tt <- exeeddat %>% filter(site_name == mysites[i])
    mylinint <- approx(x = tt$exceedance, y = tt$logYield, xout = seq(from = 0, to = 100, by = 1))
    tiblist[[i]] <- tibble(site_name = mysites[i], exceedance = mylinint$x, logYield = mylinint$y)
  }
  cvtib <- do.call(bind_rows, tiblist) %>%
    group_by(exceedance) %>%
    summarize(sdf = sd(logYield)) %>%
    ungroup()
  plot(sdf ~ exceedance, cvtib, type = "l", col = "grey40", lwd = 2, ylim = c(0,0.8))
  # panel label
  usr <- par("usr")
  par(usr = c(0,1,0,1))
  text(0.92, 0.9, labels = lab, cex = 1.2)
  par(usr = usr)
}  

Plot exceedance

Code
jpeg("C:/Users/jbaldock/OneDrive - DOI/Documents/USGS/EcoDrought/EcoDrought Working/EcoDrought-Analysis/Qualitative/EcoD_exceedance_JAS.jpg", width = 4, height = 8, units = "in", res = 1000)
par(mfrow = c(5,2), oma = c(2,2,0.5,0.5))
myplotfun_ex(subbas = "West Brook", lab = "(a)")
myplotfun_ex(subbas = "Paine Run", lab = "(b)")
myplotfun_ex(subbas = "Staunton River", lab = "(c)")
myplotfun_ex(subbas = "Big Creek", lab = "(d)")
myplotfun_ex(subbas = "Coal Creek", lab = "(e)")
myplotfun_ex(subbas = "McGee Creek", lab = "(f)")
myplotfun_ex(subbas = "Snake River", lab = "(g)")
myplotfun_ex(subbas = "Shields River", lab = "(h)")
myplotfun_ex(subbas = "Duck Creek", lab = "(i)")
myplotfun_ex(subbas = "Donner Blitzen", lab = "(j)")
mtext("log(Daily yield, mm)", outer = TRUE, side = 2, line = 0.5)
mtext("Exceedance probability", outer = TRUE, side = 1, line = 0.5)
dev.off()

#![July-September flow exceedance curves for sites in 10 headwater stream networks.](EcoD_exceedance_JAS.jpg)

Plot CV by exceedance

Code
jpeg("C:/Users/jbaldock/OneDrive - DOI/Documents/USGS/EcoDrought/EcoDrought Working/EcoDrought-Analysis/Qualitative/EcoD_exceedance_cv.jpg", width = 4, height = 8, units = "in", res = 1000)
par(mfrow = c(5,2), oma = c(2,2,0.5,0.5))
myplotfun_cv(subbas = "West Brook", lab = "(a)")
myplotfun_cv(subbas = "Paine Run", lab = "(b)")
myplotfun_cv(subbas = "Staunton River", lab = "(c)")
myplotfun_cv(subbas = "Big Creek", lab = "(d)")
myplotfun_cv(subbas = "Coal Creek", lab = "(e)")
myplotfun_cv(subbas = "McGee Creek", lab = "(f)")
myplotfun_cv(subbas = "Snake River", lab = "(g)")
myplotfun_cv(subbas = "Shields River", lab = "(h)")
myplotfun_cv(subbas = "Duck Creek", lab = "(i)")
myplotfun_cv(subbas = "Donner Blitzen", lab = "(j)")
mtext("SD of log(daily yield, mm) at little g's", outer = TRUE, side = 2, line = 0.5)
mtext("Exceedance probability", outer = TRUE, side = 1, line = 0.5)
dev.off()

#![July-September spatial variation in flow exceedance probabilities for 10 headwater stream networks.](EcoD_exceedance_cv_JAS.jpg)

11.2.3 Ridges plots

Under the current objectives/framework, I’m not sure there is much of a role for these plots. Leaving in for reference

Code
myridgesfun <- function(subbas, bigG) {
  td <- dat_clean %>% filter(subbasin == subbas)
  td2 <- td %>%
    group_by(subbasin, site_name, designation, CalendarYear, Month, MonthName) %>%
    summarize(logYield = mean(logYield)) %>%
    ungroup() %>%
    mutate(MonthName = factor(MonthName, levels = rev(c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))),
           CalendarYear = factor(CalendarYear)) 
  
  tempdat_big <- dat_clean_big %>% 
    filter(site_name == bigG, date >= min(td$date), date <= max(td$date)) %>%
    group_by(site_name, CalendarYear, Month, MonthName) %>%
    summarize(logYield = mean(logYield)) %>%
    ungroup() %>%
    mutate(MonthName = factor(MonthName, levels = rev(c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))), CalendarYear = factor(CalendarYear))
    
  return(ggplot(data = td2) +
  geom_density_ridges(data = td2, aes(x = logYield, y = MonthName), alpha = 0.5,point_alpha = 0.2) +
  geom_line(data = td2, aes(x = logYield, y = MonthName, group = site_name, color = site_name), orientation = "y", alpha = 0.3) +
  geom_point(data = td2, aes(x = logYield, y = MonthName, group = site_name, color = site_name), alpha = 0.3) +
  geom_line(data = tempdat_big, aes(x = logYield, y = MonthName, group = site_name), orientation = "y", alpha = 0.5) +
  geom_point(data =tempdat_big, aes(x = logYield, y = MonthName, group = site_name), alpha = 0.5) +
  theme_bw() + theme(legend.position = "none") +
  facet_wrap2(~CalendarYear, nrow = 3, ncol = 3, trim_blank = FALSE) +
  xlab("Monthly mean log(Yield, mm/day)") + ylab(""))
}
Code
myridgesfun(subbas = "West Brook", bigG = "South River Conway NWIS")

Code
myridgesfun(subbas = "Paine Run", bigG = "South River Harriston NWIS")

Code
myridgesfun(subbas = "Staunton River", bigG = "Rapidan River NWIS")

Code
myridgesfun(subbas = "Big Creek", bigG = "North Fork Flathead River NWIS")

Code
myridgesfun(subbas = "Coal Creek", bigG = "North Fork Flathead River NWIS")

Code
myridgesfun(subbas = "McGee Creek", bigG = "North Fork Flathead River NWIS")

Code
myridgesfun(subbas = "Snake River", bigG = "Pacific Creek at Moran NWIS")

Code
myridgesfun(subbas = "Shields River", bigG = "Yellowstone River Livingston NWIS")

Code
myridgesfun(subbas = "Duck Creek", bigG = "Yellowstone River Livingston NWIS")

Code
myridgesfun(subbas = "Donner Blitzen", bigG = "Donner Blitzen River nr Frenchglen NWIS")

11.2.4 Hysteresis

Find little g site/water years with at least 90% data completeness, join big and little g daily yield data

Code
# find little g site/water yeras with at least 90% data availability
mysiteyrs <- dat_clean %>% 
  group_by(site_name, basin, subbasin, region, WaterYear) %>% 
  summarize(numdays = n()) %>% 
  ungroup() %>% 
  filter(numdays >= 0.9*365) %>% 
  mutate(forhyst = 1) %>%
  left_join(wateravail %>% select(basin, WaterYear, totalyield_z))

# join big G data to little g
dat_clean_hyst <- dat_clean %>% 
  left_join(mysiteyrs) %>%
  filter(forhyst == 1) %>%
  left_join(dat_clean_big %>% select(basin, date, Yield_mm, logYield) %>% rename(Yield_mm_big = Yield_mm, logYield_big = logYield)) %>%
  left_join(wateravail %>% select(basin, WaterYear, totalyield_z))

Create plotting function

Code
hystplotfun <- function(mysite, wy) {
  print(dat_clean_hyst %>%
          filter(site_name == mysite, WaterYear == wy) %>%
          ggplot(aes(x = logYield_big, y = logYield, color = date)) +
          geom_segment(aes(xend = c(tail(logYield_big, n = -1), NA), yend = c(tail(logYield, n = -1), NA)), arrow = arrow(length = unit(0.2, "cm")), color = "black") +
          geom_point() + 
          geom_abline(intercept = 0, slope = 1, linetype = "dashed") + 
          scale_color_gradientn(colors = cet_pal(250, name = "c2"), trans = "date") +
          xlim(-1,1.5) + ylim(-1.5,1.8) + 
          #scale_color_scico(palette = "romaO") +
          xlab("log(Yield, mm) at reference gage") + ylab("log(Yield, mm) at headwater gage") +
          # geom_text(data = annotations, aes(x = xpos, y = ypos, label = annotateText), hjust = "inward", vjust = "inward") +
          annotate(geom = "text", x = -Inf, y = Inf, label = paste(mysite, ", WY ", wy, sep = ""), hjust = -0.1, vjust = 1.5) +
          theme_bw() + 
          theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank(),
                panel.background = element_rect(fill = "grey85"),
                axis.title = element_blank()) +
          theme(plot.margin = margin(0.1,0.1,0,0, "cm")) )
  
}

Plot example sites and years. Generally, in rain-dominated basins the East (top two rows), we see relatively little hysteresis/non-stationarity in the relationship between streamflow in headwaters and at reference gages. In contrast, in snowmelt-dominated basins of the Rocky Mountains, we see much stronger hysteresis/non-stationarity in the relationship between streamflow in headwaters and at reference gages, but this varies considerably among locations.

Code
ggarrange(hystplotfun(mysite = "West Brook NWIS", wy = 2021) + theme(legend.position = "none"),
          hystplotfun(mysite = "Jimmy Brook", wy = 2021) + theme(legend.position = "none"),
          hystplotfun(mysite = "Sanderson Brook", wy = 2021) + theme(legend.position = "none"),
          hystplotfun(mysite = "Avery Brook", wy = 2021) + theme(legend.position = "none"),
          
          hystplotfun(mysite = "Staunton River 10", wy = 2021) + theme(legend.position = "none"),
          hystplotfun(mysite = "Staunton River 06", wy = 2021) + theme(legend.position = "none"),
          hystplotfun(mysite = "Staunton River 03", wy = 2021) + theme(legend.position = "none"),
          hystplotfun(mysite = "Staunton River 02", wy = 2021) + theme(legend.position = "none"),
          
          hystplotfun(mysite = "Big Creek NWIS", wy = 2020) + theme(legend.position = "none"),
          hystplotfun(mysite = "WernerCreek", wy = 2020) + theme(legend.position = "none"),
          hystplotfun(mysite = "CycloneCreekUpper", wy = 2020) + theme(legend.position = "none"),
          hystplotfun(mysite = "McGeeCreekTrib", wy = 2020) + theme(legend.position = "none"),
          
          hystplotfun(mysite = "Buck Creek", wy = 2022) + theme(legend.position = "none"),
          hystplotfun(mysite = "Dugout Creek", wy = 2022) + theme(legend.position = "none"),
          hystplotfun(mysite = "EF Duck Creek be HF", wy = 2022) + theme(legend.position = "none"),
          leg,
          
          nrow = 4, ncol = 4) %>%
  annotate_figure(left = text_grob("log(Yield, mm) at headwater gage", rot = 90),
                  bottom = text_grob("log(Yield, mm) at reference gage"))

WB NWIS
Code
ggplotly(hystplotfun(mysite = "West Brook NWIS", wy = 2021))

Jimmy
Code
ggplotly(hystplotfun(mysite = "Jimmy Brook", wy = 2021))

Sanderson
Code
ggplotly(hystplotfun(mysite = "Sanderson Brook", wy = 2021))

Avery
Code
ggplotly(hystplotfun(mysite = "Avery Brook", wy = 2021))

SR 10
Code
ggplotly(hystplotfun(mysite = "Staunton River 10", wy = 2021))

SR 06
Code
ggplotly(hystplotfun(mysite = "Staunton River 06", wy = 2021))

SR 03
Code
ggplotly(hystplotfun(mysite = "Staunton River 03", wy = 2021))

SR 02
Code
ggplotly(hystplotfun(mysite = "Staunton River 02", wy = 2021))

Big Creek NWIS
Code
ggplotly(hystplotfun(mysite = "Big Creek NWIS", wy = 2020))

Werner
Code
ggplotly(hystplotfun(mysite = "WernerCreek", wy = 2020))

Cyclone Upper
Code
ggplotly(hystplotfun(mysite = "CycloneCreekUpper", wy = 2020))

McGee Trib
Code
ggplotly(hystplotfun(mysite = "McGeeCreekTrib", wy = 2020))

Buck
Code
ggplotly(hystplotfun(mysite = "Buck Creek", wy = 2022))

Dugout
Code
ggplotly(hystplotfun(mysite = "Dugout Creek", wy = 2022))

Duck be HF
Code
ggplotly(hystplotfun(mysite = "EF Duck Creek be HF", wy = 2022))

11.3 Objective 2

11.4 Objective 3

Objective 3: Demonstrate how drought-related low flow conditions manifest differently in streams across headwater networks.

Approach:

  • Using fixed and seasonally variable low flow/drought thresholds derived from long-term (1970-present) big G data (sensu Hammond et al. 2022), show how streamflow drought duration and deficit vary among headwater streams (relative to big G).
    • Heat maps showing the timing/onset of low flow conditions across big G and little g’sG
    • Drought deficit/duration violin plots with points for little g’s relative to big G
  • Show how does the spread of values (spatial variation in drought duration and deficit) changes among years that differ in regional water availability

Notes:

  • not sure how to accomplish (2) given that the number and collection of sites per (sub)basin changes considerably among years/months

11.4.1 Low flow thresholds

Generate fixed and time varying (by day of year) drought/low flow thresholds from long-term (1970-2025) big G streamflow data. Quantiles correspond to those used in Hammond et al. (2022): 0.30, 0.20, 0.10, 0.05, 0.02.

Code
# calculate site-level fixed low flow thresholds
dat_clean_big_fixed <- dat_clean_big %>% 
  group_by(site_name, basin, subbasin, region) %>%
  summarize(thresh_30_fix = quantile(Yield_mm, probs = 0.3, na.rm = TRUE),
            thresh_20_fix = quantile(Yield_mm, probs = 0.2, na.rm = TRUE),
            thresh_10_fix = quantile(Yield_mm, probs = 0.1, na.rm = TRUE),
            thresh_5_fix = quantile(Yield_mm, probs = 0.05, na.rm = TRUE),
            thresh_2_fix = quantile(Yield_mm, probs = 0.02, na.rm = TRUE)) %>%
  ungroup()
(dat_clean_big_fixed)
# A tibble: 16 × 9
   site_name     basin subbasin region thresh_30_fix thresh_20_fix thresh_10_fix
   <chr>         <chr> <chr>    <chr>          <dbl>         <dbl>         <dbl>
 1 Battle Run N… Pine… Piney R… Shen           0.319         0.211         0.106
 2 Battle Run N… <NA>  <NA>     <NA>          NA            NA            NA    
 3 Donner Blitz… Donn… Donner … Oreg           0.201         0.173         0.152
 4 Donner Blitz… <NA>  <NA>     <NA>          NA            NA            NA    
 5 North Fork F… Flat… Flathead Flat           0.484         0.406         0.333
 6 North Fork F… <NA>  <NA>     <NA>          NA            NA            NA    
 7 Pacific Cree… Snak… Snake R… Snake          0.284         0.250         0.211
 8 Pacific Cree… <NA>  <NA>     <NA>          NA            NA            NA    
 9 Rapidan Rive… Stau… Staunto… Shen           0.472         0.312         0.174
10 Rapidan Rive… <NA>  <NA>     <NA>          NA            NA            NA    
11 South River … West… West Br… Mass           0.731         0.492         0.308
12 South River … <NA>  <NA>     <NA>          NA            NA            NA    
13 South River … Pain… Paine R… Shen           0.450         0.370         0.307
14 South River … <NA>  <NA>     <NA>          NA            NA            NA    
15 Yellowstone … Shie… Shields… Shiel…         0.388         0.346         0.304
16 Yellowstone … <NA>  <NA>     <NA>          NA            NA            NA    
# ℹ 2 more variables: thresh_5_fix <dbl>, thresh_2_fix <dbl>
Code
# calculate site-level variable (by doy) low flow thresholds
dat_clean_big_variable <- dat_clean_big %>% 
  group_by(site_name, basin, subbasin, region, doy_calendar) %>%
  summarize(thresh_30_var = quantile(Yield_mm, probs = 0.3, na.rm = TRUE),
            thresh_20_var = quantile(Yield_mm, probs = 0.2, na.rm = TRUE),
            thresh_10_var = quantile(Yield_mm, probs = 0.1, na.rm = TRUE),
            thresh_5_var = quantile(Yield_mm, probs = 0.05, na.rm = TRUE),
            thresh_2_var = quantile(Yield_mm, probs = 0.02, na.rm = TRUE)) %>%
  ungroup()
(dat_clean_big_variable)
# A tibble: 2,936 × 10
   site_name      basin subbasin region doy_calendar thresh_30_var thresh_20_var
   <chr>          <chr> <chr>    <chr>         <dbl>         <dbl>         <dbl>
 1 Battle Run NW… Pine… Piney R… Shen              1         0.582         0.390
 2 Battle Run NW… Pine… Piney R… Shen              2         0.547         0.382
 3 Battle Run NW… Pine… Piney R… Shen              3         0.582         0.432
 4 Battle Run NW… Pine… Piney R… Shen              4         0.619         0.405
 5 Battle Run NW… Pine… Piney R… Shen              5         0.571         0.428
 6 Battle Run NW… Pine… Piney R… Shen              6         0.559         0.429
 7 Battle Run NW… Pine… Piney R… Shen              7         0.547         0.461
 8 Battle Run NW… Pine… Piney R… Shen              8         0.539         0.439
 9 Battle Run NW… Pine… Piney R… Shen              9         0.557         0.407
10 Battle Run NW… Pine… Piney R… Shen             10         0.605         0.492
# ℹ 2,926 more rows
# ℹ 3 more variables: thresh_10_var <dbl>, thresh_5_var <dbl>,
#   thresh_2_var <dbl>

Join drought thresholds derived from big G to little g’s

Code
# little gs
dat_clean_little_join <- dat_clean %>% 
  left_join(dat_clean_big_fixed %>% select(-c(site_name, subbasin))) %>%
  left_join(dat_clean_big_variable %>% select(-c(site_name, subbasin))) %>%
  mutate(month = month(date),
         year = year(date),
         designation = "little",
         drought_fix = ifelse(Yield_mm <= thresh_30_fix & Yield_mm > thresh_20_fix, "q30", 
                              ifelse(Yield_mm <= thresh_20_fix & Yield_mm > thresh_10_fix, "q20", 
                                     ifelse(Yield_mm <= thresh_10_fix & Yield_mm > thresh_5_fix, "q10",
                                            ifelse(Yield_mm <= thresh_5_fix & Yield_mm > thresh_2_fix, "q05", 
                                                   ifelse(Yield_mm <= thresh_2_fix, "q02", "none"))))),
         drought_var = ifelse(Yield_mm <= thresh_30_var & Yield_mm > thresh_20_var, "q30", 
                              ifelse(Yield_mm <= thresh_20_var & Yield_mm > thresh_10_var, "q20", 
                                     ifelse(Yield_mm <= thresh_10_var & Yield_mm > thresh_5_var, "q10",
                                            ifelse(Yield_mm <= thresh_5_var & Yield_mm > thresh_2_var, "q05", 
                                                   ifelse(Yield_mm <= thresh_2_var, "q02", "none")))))) %>%
  mutate(drought_fix = factor(ifelse(is.na(Yield_mm), NA, drought_fix), levels = c("none", "q30", "q20", "q10", "q05", "q02")),
         drought_var = factor(ifelse(is.na(Yield_mm), NA, drought_var), levels = c("none", "q30", "q20", "q10", "q05", "q02"))) 

# big gs
dat_clean_big_join <- dat_clean_big %>% 
  left_join(dat_clean_big_fixed %>% select(-c(site_name, subbasin))) %>%
  left_join(dat_clean_big_variable %>% select(-c(site_name, subbasin))) %>%
  mutate(month = month(date),
         year = year(date),
         designation = "big",
         drought_fix = ifelse(Yield_mm <= thresh_30_fix & Yield_mm > thresh_20_fix, "q30", 
                              ifelse(Yield_mm <= thresh_20_fix & Yield_mm > thresh_10_fix, "q20", 
                                     ifelse(Yield_mm <= thresh_10_fix & Yield_mm > thresh_5_fix, "q10",
                                            ifelse(Yield_mm <= thresh_5_fix & Yield_mm > thresh_2_fix, "q05", 
                                                   ifelse(Yield_mm <= thresh_2_fix, "q02", "none"))))),
         drought_var = ifelse(Yield_mm <= thresh_30_var & Yield_mm > thresh_20_var, "q30", 
                              ifelse(Yield_mm <= thresh_20_var & Yield_mm > thresh_10_var, "q20", 
                                     ifelse(Yield_mm <= thresh_10_var & Yield_mm > thresh_5_var, "q10",
                                            ifelse(Yield_mm <= thresh_5_var & Yield_mm > thresh_2_var, "q05", 
                                                   ifelse(Yield_mm <= thresh_2_var, "q02", "none")))))) %>%
  mutate(drought_fix = factor(ifelse(is.na(Yield_mm), NA, drought_fix), levels = c("none", "q30", "q20", "q10", "q05", "q02")),
         drought_var = factor(ifelse(is.na(Yield_mm), NA, drought_var), levels = c("none", "q30", "q20", "q10", "q05", "q02"))) 
dat_clean_big_join_sub <- dat_clean_big_join %>% left_join(yrdf) %>% filter(ecodyr == "yes")

# join data
dat_clean_join <- bind_rows(dat_clean_little_join, dat_clean_big_join_sub)

11.4.2 Low flow heatmaps

Create heatmap functions

Code
# fixed drought threshold
heatmapfun_fix <- function(subbas, months, bigG) {
  dd <- dat_clean_join %>% filter(subbasin == subbas | site_name == bigG, month %in% months)
  mysites <- c(unique(unlist(dd %>% filter(designation == "big") %>% select(site_name))),
               unique(unlist(dd %>% filter(designation == "little") %>% select(site_name))))
  myrect <- dd %>% group_by(WaterYear) %>% summarize(mindate = min(date), maxdate = max(date)) %>% ungroup()
  p <- dd %>%
    ggplot() +
    geom_tile(aes(x = date, y = factor(site_name, levels = rev(mysites)), fill = drought_fix)) +
    scale_fill_viridis(option = "A", direction = -1, discrete = TRUE, limits = c("none", "q30", "q20", "q10", "q05", "q02")) +
    geom_rect(data = myrect, aes(xmin = mindate, xmax = maxdate, ymin = length(mysites)-0.5, ymax = length(mysites)+0.5), 
              color = "grey70", fill = NA, size = 1.25) +
    xlab("Date") + ylab("Site") +
    #facet_wrap(~WaterYear, scales = "free_x") + 
    facet_wrap2(~WaterYear, scales = "free_x", nrow = 3, ncol = 3, trim_blank = FALSE) +
    theme_bw() + theme(axis.title = element_blank())
return(p)
}
# variable drought threshold
heatmapfun_var <- function(subbas, months, bigG) {
  dd <- dat_clean_join %>% filter(subbasin == subbas | site_name == bigG, month %in% months)
  mysites <- c(unique(unlist(dd %>% filter(designation == "big") %>% select(site_name))),
               unique(unlist(dd %>% filter(designation == "little") %>% select(site_name))))
  myrect <- dd %>% group_by(WaterYear) %>% summarize(mindate = min(date), maxdate = max(date)) %>% ungroup()
  p <- dd %>%
    ggplot() +
    geom_tile(aes(x = date, y = factor(site_name, levels = rev(mysites)), fill = drought_var)) +
    scale_fill_viridis(option = "A", direction = -1, discrete = TRUE, limits = c("none", "q30", "q20", "q10", "q05", "q02")) +
    geom_rect(data = myrect, aes(xmin = mindate, xmax = maxdate, ymin = length(mysites)-0.5, ymax = length(mysites)+0.5), 
              color = "grey70", fill = NA, size = 1.25) +
    xlab("Date") + ylab("Site") +
    #facet_wrap(~WaterYear, scales = "free_x") +
    facet_wrap2(~WaterYear, scales = "free_x", nrow = 3, ncol = 3, trim_blank = FALSE) +
    theme_bw() + theme(axis.title = element_blank())
return(p)
}

11.4.2.1 Fixed threshold

Code
heatmapfun_fix(subbas = "West Brook", bigG = "South River Conway NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "Paine Run", bigG = "South River Harriston NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "Staunton River", bigG = "Rapidan River NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "Big Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "Coal Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "McGee Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "Snake River", bigG = "Pacific Creek at Moran NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "Shields River", bigG = "Yellowstone River Livingston NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "Duck Creek", bigG = "Yellowstone River Livingston NWIS", months = c(7:9))

Code
heatmapfun_fix(subbas = "Donner Blitzen", bigG = "Donner Blitzen River nr Frenchglen NWIS", months = c(7:9))

11.4.2.2 Variable threshold

Code
heatmapfun_var(subbas = "West Brook", bigG = "South River Conway NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "Paine Run", bigG = "South River Harriston NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "Staunton River", bigG = "Rapidan River NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "Big Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "Coal Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "McGee Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "Snake River", bigG = "Pacific Creek at Moran NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "Shields River", bigG = "Yellowstone River Livingston NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "Duck Creek", bigG = "Yellowstone River Livingston NWIS", months = c(7:9))

Code
heatmapfun_var(subbas = "Donner Blitzen", bigG = "Donner Blitzen River nr Frenchglen NWIS", months = c(7:9))

11.4.3 Deficit and duration

Calculate daily deficit, then summarize deficit magnitude and duration by site and month.

Code
# calculate daily deficit
dat_clean_join_deficit <- dat_clean_join %>%
  mutate(deficit_30_fix = ifelse(Yield_mm < thresh_30_fix, thresh_30_fix - Yield_mm, 0),
         deficit_20_fix = ifelse(Yield_mm < thresh_20_fix, thresh_20_fix - Yield_mm, 0),
         deficit_10_fix = ifelse(Yield_mm < thresh_10_fix, thresh_10_fix - Yield_mm, 0),
         deficit_5_fix = ifelse(Yield_mm < thresh_5_fix, thresh_5_fix - Yield_mm, 0),
         deficit_2_fix = ifelse(Yield_mm < thresh_2_fix, thresh_2_fix - Yield_mm, 0),
         deficit_30_var = ifelse(Yield_mm < thresh_30_var, thresh_30_var - Yield_mm, 0),
         deficit_20_var = ifelse(Yield_mm < thresh_20_var, thresh_20_var - Yield_mm, 0),
         deficit_10_var = ifelse(Yield_mm < thresh_10_var, thresh_10_var - Yield_mm, 0),
         deficit_5_var = ifelse(Yield_mm < thresh_5_var, thresh_5_var - Yield_mm, 0),
         deficit_2_var = ifelse(Yield_mm < thresh_2_var, thresh_2_var - Yield_mm, 0))

# fill missing dates
dat_clean_join_deficit <- fill_missing_dates(dat_clean_join_deficit, dates = date, groups = site_name, pad_ends = TRUE)

# fill ragged basin, subbasin, region, date variables
dat_clean_join_deficit <- dat_clean_join_deficit %>% 
  select(-c(basin, subbasin, region, CalendarYear, Month, MonthName, WaterYear, DayofYear, designation)) %>% 
  left_join(siteinfo %>% 
              mutate(designation = ifelse(site_name %in% unique(dat_clean_big$site_name), "big", "little")) %>% 
              select(site_name, basin, subbasin, region, designation))
dat_clean_join_deficit <- add_date_variables(dat_clean_join_deficit, dates = date, water_year_start = 10)

# summarize by month
defdur_month <- dat_clean_join_deficit %>% 
  group_by(site_name, basin, subbasin, region, designation, CalendarYear, Month, MonthName, WaterYear) %>% 
  summarize(duration_30_fix = sum(deficit_30_fix > 0),
            duration_20_fix = sum(deficit_20_fix > 0),
            duration_10_fix = sum(deficit_10_fix > 0),
            duration_5_fix = sum(deficit_5_fix > 0),
            duration_2_fix = sum(deficit_2_fix > 0),
            duration_30_var = sum(deficit_30_var > 0),
            duration_20_var = sum(deficit_20_var > 0),
            duration_10_var = sum(deficit_10_var > 0),
            duration_5_var = sum(deficit_5_var > 0),
            duration_2_var = sum(deficit_2_var > 0),
            deficit_30_fix = sum(deficit_30_fix),
            deficit_20_fix = sum(deficit_20_fix),
            deficit_10_fix = sum(deficit_10_fix),
            deficit_5_fix = sum(deficit_5_fix),
            deficit_2_fix = sum(deficit_2_fix),
            deficit_30_var = sum(deficit_30_var),
            deficit_20_var = sum(deficit_20_var),
            deficit_10_var = sum(deficit_10_var),
            deficit_5_var = sum(deficit_5_var),
            deficit_2_var = sum(deficit_2_var)) %>%
  ungroup() %>%
  left_join(wateravail %>% select(basin, WaterYear, totalyield, totalyield_z))

Create violin plot function. Don’t love this plotting style, but shows that data reasonably well

Code
defdurplotfun <- function(subbas, bigG, months) {
  dd_little <- defdur_month %>% filter(subbasin == subbas, Month %in% months, designation == "little")
  myyrs <- unique(dd_little$WaterYear)
  dd_little <- dd_little %>% mutate(WaterYear = factor(WaterYear, levels = (sort(myyrs))))
  dd_big <- defdur_month %>% 
    filter(site_name == bigG, Month %in% months) %>% 
    mutate(WaterYear = factor(WaterYear, levels = (sort(myyrs)))) %>% 
    filter(WaterYear %in% unique(myyrs))

  m <- 7
  p_def_7 <- ggplot() +
    geom_violin(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, fill = totalyield_z), trim = TRUE, scale = "width") +
    scale_fill_gradient2(low = "red", mid = "white", high = "blue", midpoint = 0) + 
    geom_line(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name, color = site_name), orientation = "y") +
    geom_point(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name, color = site_name)) +
    geom_line(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name), orientation = "y") +
    geom_point(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name), size = 2) +
    coord_flip() +
    theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
  p_dur_7 <- ggplot() +
    geom_violin(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, fill = totalyield_z), trim = TRUE, scale = "width") +
    scale_fill_gradient2(low = "red", mid = "white", high = "blue", midpoint = 0) + 
    geom_line(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name, color = site_name), orientation = "y") +
    geom_point(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name, color = site_name)) +
    geom_line(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name), orientation = "y") +
    geom_point(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name), size = 2) +
    coord_flip() +
    theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

  m <- 8
  p_def_8 <- ggplot() +
    geom_violin(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, fill = totalyield_z), trim = TRUE, scale = "width") +
    scale_fill_gradient2(low = "red", mid = "white", high = "blue", midpoint = 0) + 
    geom_line(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name, color = site_name), orientation = "y") +
    geom_point(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name, color = site_name)) +
    geom_line(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name), orientation = "y") +
    geom_point(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name), size = 2) +
    coord_flip() +
    theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
  p_dur_8 <- ggplot() +
    geom_violin(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, fill = totalyield_z), trim = TRUE, scale = "width") +
    scale_fill_gradient2(low = "red", mid = "white", high = "blue", midpoint = 0) + 
    geom_line(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name, color = site_name), orientation = "y") +
    geom_point(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name, color = site_name)) +
    geom_line(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name), orientation = "y") +
    geom_point(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name), size = 2) +
    coord_flip() +
    theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

  m <- 9
  p_def_9 <- ggplot() +
    geom_violin(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, fill = totalyield_z), trim = TRUE, scale = "width") +
    scale_fill_gradient2(low = "red", mid = "white", high = "blue", midpoint = 0) + 
    geom_line(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name, color = site_name), orientation = "y") +
    geom_point(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name, color = site_name)) +
    geom_line(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name), orientation = "y") +
    geom_point(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = deficit_10_fix, group = site_name), size = 2) +
    coord_flip() +
    theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
  p_dur_9 <- ggplot() +
    geom_violin(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, fill = totalyield_z), trim = TRUE, scale = "width") +
    scale_fill_gradient2(low = "red", mid = "white", high = "blue", midpoint = 0) + 
    geom_line(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name, color = site_name), orientation = "y") +
    geom_point(data = dd_little %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name, color = site_name)) +
    geom_line(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name), orientation = "y") +
    geom_point(data = dd_big %>% filter(Month == m), aes(y = WaterYear, x = duration_10_fix, group = site_name), size = 2) +
    coord_flip() +
    theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

  return(ggarrange(p_def_7, p_def_8, p_def_9,
                   p_dur_7, p_dur_8, p_dur_9, 
                   nrow = 2, ncol = 3, common.legend = TRUE, legend = "right") %>% 
           annotate_figure(top = "July                                                             August                                                  September"))
}
Code
defdurplotfun(subbas = "West Brook", bigG = "South River Conway NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "Paine Run", bigG = "South River Harriston NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "Staunton River", bigG = "Rapidan River NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "Big Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "Coal Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "McGee Creek", bigG = "North Fork Flathead River NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "Snake River", bigG = "Pacific Creek at Moran NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "Shields River", bigG = "Yellowstone River Livingston NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "Duck Creek", bigG = "Yellowstone River Livingston NWIS", months = c(7:9))

Code
defdurplotfun(subbas = "Donner Blitzen", bigG = "Donner Blitzen River nr Frenchglen NWIS", months = c(7:9))

11.5 Objective 4

11.6 OLD

11.6.1 Spatiotemporal variation

How does the spatial variation in stream flow compare to temporal variation in streamflow at a single reference location?

Create plotting function

Code
myplotfun_spacetime <- function(subbas) {
  # format data
  data_sub <- dat_clean %>% filter(subbasin == subbas)
  sitesdesig <- data_sub %>% group_by(site_name) %>% summarize(designation = unique(designation), ss = n()) %>% ungroup()
  data_sub_com <- data_sub %>% 
    select(date, site_name, logYield) %>%
    spread(key = site_name, value = logYield) %>% 
    drop_na() %>%
    gather(key = site_name, value = logYield, 2:ncol(.))
  data_sub_com_little <- data_sub_com %>% filter(site_name %in% unlist(sitesdesig %>% filter(designation == "little") %>% select(site_name)))
  data_sub_com_big <- data_sub_com %>% filter(site_name %in% unlist(sitesdesig %>% filter(designation == "big") %>% select(site_name)))
  # calculate spatial and temporal variation 
  temporal_sd <- sd(data_sub_com_big$logYield)
  relsd_ts <- data_sub_com_little %>% 
    group_by(date) %>%
    summarize(little_sdlf = sd(logYield)) %>% 
    ungroup() %>%
    mutate(big_temporal_sdlf = temporal_sd,
           relsdlf = little_sdlf - big_temporal_sdlf) %>%
    left_join(data_sub_com_big)
  # plot time series
  par(mfrow = c(1,2), mar = c(3,3,0.5,0.5), mgp = c(2,0.6,0))
  plot(relsdlf ~ date, relsd_ts, xlab = "Date", ylab = "Spatial SD - temporal SD")
  abline(h = 0, col = "red", lty = 2)
  #par(mar = c(3,3,0.1,0.1), mgp = c(2.5,0.6,0))
  legend("topright", legend = subbas, bty = "n")
  # plot sd by big G flow
  plot(relsdlf ~ logYield, relsd_ts, axes = FALSE, xlab = "log(Yield at big G)", ylab = "")
  axis(1)
  axis(2, labels = NA)
  box(bty = "O")
  abline(h = 0, col = "red", lty = 2)
}
Code
myplotfun_spacetime(subbas = "West Brook")
Code
myplotfun_spacetime(subbas = "Paine Run")
Code
myplotfun_spacetime(subbas = "Staunton River")
Code
myplotfun_spacetime(subbas = "Big Creek")
Code
myplotfun_spacetime(subbas = "Coal Creek")
Code
myplotfun_spacetime(subbas = "McGee Creek")
Code
myplotfun_spacetime(subbas = "Snake River")
Code
myplotfun_spacetime(subbas = "Shields River")
Code
myplotfun_spacetime(subbas = "Duck Creek")
Code
myplotfun_spacetime(subbas = "Donner Blitzen")

11.6.2 Flow by Climate

Load drought/climate metrics data and view temporal range of 1-month SPI and DSCI.

Code
drought <- read_csv("C:/Users/jbaldock/OneDrive - DOI/Documents/USGS/EcoDrought/EcoDrought Working/EcoDrought-Analysis/Explore Data/EcoD_Basin_MonthlyDroughtMetrics.csv") %>% rename(Month = month, CalendarYear = year) #%>% select(-date)

datatable(drought %>% select(basin, date, spi_1, dsci_monthly_1) %>% gather(key = "metric", value = "value", spi_1:dsci_monthly_1) %>% drop_na() %>% group_by(basin, metric) %>% summarize(mindate = min(date), maxdate = max(date)))

Show distribtuions of SPI and DSCI during recent years, by basin

Code
# SPI
drought %>% 
  filter(CalendarYear >= 2016) %>% 
  select(basin, CalendarYear, Month, date, spi_1, spi_6, spi_12, spi_24) %>% 
  gather(key = "metric", value = "value", spi_1:spi_24) %>%
  mutate(metric = factor(metric, levels = c("spi_1", "spi_6", "spi_12", "spi_24"))) %>%
  ggplot(aes(x = basin, y = value, fill = metric)) +
  geom_boxplot() +
  xlab("") + ylab("Standardized Precipitation Index (2016-2023)") +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

Code
# DSCI
drought %>% 
  filter(CalendarYear >= 2016) %>% 
  select(basin, CalendarYear, Month, date, dsci_monthly_1, dsci_monthly_6, dsci_monthly_12, dsci_monthly_24) %>% 
  gather(key = "metric", value = "value", dsci_monthly_1:dsci_monthly_24) %>%
  mutate(metric = factor(metric, levels = c("dsci_monthly_1", "dsci_monthly_6", "dsci_monthly_12", "dsci_monthly_24"))) %>%
  ggplot(aes(x = basin, y = value, fill = metric)) +
  geom_boxplot() +
  xlab("") + ylab("Drought Severity and Coverage Index (2016-2024)") +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

Create plotting function

Code
myplotfun_mmq <- function(subbas) {
  # summarize monthly mean yield by site, year
  tt <- dat_clean %>% 
    mutate(basin = ifelse(subbasin == "Duck Creek", "Shields River", basin)) %>%
    filter(!is.na(logYield)) %>%
    group_by(region, basin, subbasin, site_name, designation, CalendarYear, Month) %>%
    summarize(meanQ = mean(logYield, na.rm = TRUE), nobs = n()) %>%
    ungroup() %>%
    filter(nobs >= 27) %>%
    left_join(drought) 
  
  # filter to focal subbasin, keep only sites/months with at least 3 years of data
  tt2 <- tt %>% filter(subbasin == subbas) %>% mutate(keep = paste(site_name, Month, sep = "_"))
  keeps <- tt2 %>% 
    group_by(site_name, Month) %>% 
    summarize(nobs = n()) %>% 
    filter(nobs >= 3) %>% 
    mutate(keep = paste(site_name, Month, sep = "_"))
  tt2_little <- tt2 %>% filter(keep %in% keeps$keep, designation == "little", Month %in% c(6:10))
  tt2_big <- tt2 %>% filter(keep %in% keeps$keep, designation == "big", Month %in% c(6:10))

  # plot SPI-9
  p1 <- ggplot() +
    geom_point(data = tt2_little, aes(x = spi_9, y = meanQ, color = site_name, group = site_name)) +
    geom_smooth(data = tt2_little, aes(x = spi_9, y = meanQ, color = site_name, group = site_name), method = "lm", se = FALSE) +
    geom_point(data = tt2_big, aes(x = spi_9, y = meanQ), color = "black") +
    geom_smooth(data = tt2_big, aes(x = spi_9, y = meanQ), color = "black", method = "lm", se = FALSE) +
    facet_wrap(~Month, nrow = 1) +
    theme_bw() + theme(legend.position = "none", panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
    xlab("Standardized precipitation index, 9 month") + ylab("Mean monthly log(yield)")
  
  # plot DSCI-1
  p2 <- ggplot() +
    geom_point(data = tt2_little, aes(x = dsci_monthly_1, y = meanQ, color = site_name, group = site_name)) +
    geom_smooth(data = tt2_little, aes(x = dsci_monthly_1, y = meanQ, color = site_name, group = site_name), method = "lm", se = FALSE) +
    geom_point(data = tt2_big, aes(x = dsci_monthly_1, y = meanQ), color = "black") +
    geom_smooth(data = tt2_big, aes(x = dsci_monthly_1, y = meanQ), color = "black", method = "lm", se = FALSE) +
    facet_wrap(~Month, nrow = 1) +
    theme_bw() + theme(legend.position = "none", panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
    xlab("Drought severity and coverage index, 1 month") + ylab("Mean monthly log(yield)")
  
  # combine plots
  ggarrange(p1, p2, nrow = 2)
}
Code
myplotfun_mmq(subbas = "West Brook")

Code
myplotfun_mmq(subbas = "Paine Run")

Code
myplotfun_mmq(subbas = "Staunton River")

Code
myplotfun_mmq(subbas = "Big Creek")

Code
myplotfun_mmq(subbas = "Coal Creek")

Code
myplotfun_mmq(subbas = "McGee Creek")

Code
myplotfun_mmq(subbas = "Snake River")

Code
myplotfun_mmq(subbas = "Shields River")

Code
myplotfun_mmq(subbas = "Duck Creek")

Code
myplotfun_mmq(subbas = "Donner Blitzen")

11.6.3 Similarity by Climate

Code
myplotfun_dist <- function(subbas, distance = c("euclidean", "manhattan")) {
  
  # filter by subbasin
  data_sub <- dat_clean %>% 
    mutate(basin = ifelse(subbasin == "Duck Creek", "Shields River", basin)) %>%
    filter(subbasin == subbas)
  
  # little g's
  data_sub_little <- data_sub %>% 
    filter(designation == "little") %>% 
    select(site_name, basin, subbasin, date, CalendarYear, Month, logYield)
  
  # big G
  data_sub_big <- data_sub %>% 
    filter(designation == "big") %>% 
    select(basin, subbasin, date, CalendarYear, Month, logYield) %>%
    rename(logYield_big = logYield)
  
  # join little and big
  data_sub_join <- data_sub_little %>% full_join(data_sub_big)
  
  # calculate time series similarity metrics
  dist_sum <- data_sub_join %>% 
    group_by(basin, site_name, CalendarYear, Month) %>% 
    summarize(numdays = n(),
              dist_ts = ifelse(distance == "euclidean", 
                               EuclideanDistance(logYield, logYield_big),
                               ManhattanDistance(logYield, logYield_big))) %>% 
    ungroup() %>%
    left_join(drought) %>%
    filter(numdays >= 27, Month %in% c(6:10)) %>% 
    mutate(keep = paste(site_name, Month, sep = "_"))
  
  # filter to focal subbasin, keep only sites/months with at least 3 years of data
  keeps <- dist_sum %>% 
    group_by(site_name, Month) %>% 
    summarize(nobs = n()) %>% 
    filter(nobs >= 3) %>% 
    mutate(keep = paste(site_name, Month, sep = "_"))
  dist_sum <- dist_sum %>% filter(keep %in% keeps$keep)
  
  # Plots
  p1 <- dist_sum %>% 
    ggplot(aes(x = spi_9, y = dist_ts, color = site_name, group = site_name)) +
    geom_point() +
    geom_smooth(method = "lm", se = FALSE) +
    facet_wrap(~Month, nrow = 1) +
    theme_bw() + theme(legend.position = "none", panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
    xlab("Standardized precipitation index, 9 month") + ylab("Distance")
  p2 <- dist_sum %>% 
    ggplot(aes(x = dsci_monthly_1, y = dist_ts, color = site_name, group = site_name)) +
    geom_point() +
    geom_smooth(method = "lm", se = FALSE) +
    facet_wrap(~Month, nrow = 1) +
    theme_bw() + theme(legend.position = "none", panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
    xlab("Drought severity and coverage index, 1 month") + ylab("Distance")
  
  # combine plots
  ggarrange(p1, p2, nrow = 2)
}
Code
myplotfun_dist(subbas = "West Brook", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "Paine Run", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "Staunton River", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "Big Creek", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "Coal Creek", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "McGee Creek", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "Snake River", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "Shields River", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "Duck Creek", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
myplotfun_dist(subbas = "Donner Blitzen", distance = "euclidean")
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.
Error : There are missing values in the series.

Code
# summarize monthly mean yield by site, year
tt <- dat_clean %>% 
    mutate(basin = ifelse(subbasin == "Duck Creek", "Shields River", basin)) %>%
    filter(!is.na(logYield), designation == "little") %>%
    group_by(region, basin, subbasin, site_name, designation, CalendarYear, Month) %>%
    summarize(meanQ = mean(logYield, na.rm = TRUE), nobs = n()) %>%
    ungroup() %>%
    filter(nobs >= 27) %>%
    left_join(drought) 

# calculate correlations
mylist_dsci_slope <- list()
mylist_dsci_pval <- list()
mylist_dsci_rho <- list()
mylist_spi_slope <- list()
mylist_spi_pval <- list()
mylist_spi_rho <- list()

# list of sites to iterate over
sites <- unique(tt$site_name)

for(i in 1:length(sites)) {
  d <- tt %>% filter(site_name == sites[i])
  mymat_dsci_slope <- matrix(data = NA, nrow = 12, ncol = 24)
  mymat_dsci_pval <- matrix(data = NA, nrow = 12, ncol = 24)
  mymat_dsci_rho <- matrix(data = NA, nrow = 12, ncol = 24)
  mymat_spi_slope <- matrix(data = NA, nrow = 12, ncol = 24)
  mymat_spi_pval <- matrix(data = NA, nrow = 12, ncol = 24)
  mymat_spi_rho <- matrix(data = NA, nrow = 12, ncol = 24)
  for(j in 1:12) {
    for(k in 1:24) {
      if(nrow(d %>% filter(Month == j)) < 3) next
      # DSCI
      d2 <- d %>% filter(Month == j) %>% select(meanQ, paste("dsci_monthly_", k, sep = ""))
      ## slope and p-value
      try(mylm <- lm(unlist(d2[,1]) ~ unlist(d2[,2])), silent = TRUE)
      try(mymat_dsci_slope[j,k] <- summary(mylm)$coefficients[2,1], silent = TRUE)
      try(mymat_dsci_pval[j,k] <- summary(mylm)$coefficients[2,4], silent = TRUE)
      ## pearons r correlation
      try(mymat_dsci_rho[j,k] <- cor(d2[,1], d2[,2], method = "pearson", use = "complete.obs"), silent = TRUE)
      
      # SPI
      d2 <- d %>% filter(Month == j) %>% select(meanQ, paste("spi_", k, sep = ""))
      ## slope and p-value
      try(mylm <- lm(unlist(d2[,1]) ~ unlist(d2[,2])), silent = TRUE)
      try(mymat_spi_slope[j,k] <- summary(mylm)$coefficients[2,1], silent = TRUE)
      try(mymat_spi_pval[j,k] <- summary(mylm)$coefficients[2,4], silent = TRUE)
      ## pearons r correlation
      try(mymat_spi_rho[j,k] <- cor(d2[,1], d2[,2], method = "pearson", use = "complete.obs"), silent = TRUE)
    }
  }
  mylist_dsci_slope[[i]] <- mymat_dsci_slope
  mylist_dsci_pval[[i]] <- mymat_dsci_pval
  mylist_dsci_rho[[i]] <- mymat_dsci_rho
  mylist_spi_slope[[i]] <- mymat_spi_slope
  mylist_spi_pval[[i]] <- mymat_spi_pval
  mylist_spi_rho[[i]] <- mymat_spi_rho
  print(i)
}




# generate plots/heatmaps of correlation
n <- 100
for(i in 1:length(sites)) {
  # streamflow mean ~ DSCI
  jpeg(paste("./Climate Sensitivity/Climate sensitivity plots/Streamflow_DSCI_correlation_TimeVarying_", "site", i, "_mean.jpg", sep = ""), height = 6, width = 7, units = "in", res = 500)
  filled.contour(x = 1:24, y = 1:12, z = t(corlist_dsci_mean[[i]]), 
                 levels = seq(from = -1, to = 1, length = n+1), col = hcl.colors(n, "PRGn"),
                 plot.title = title(main = sites[i], 
                                    xlab = "DSCI - accumulation time scale (months)", 
                                    ylab = "Month"),
                 plot.axes = { 
                   axis(1, at = seq(from = 1, to = 23, by = 2))
                   axis(2, at = 1:12, labels = c("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D")) 
                   contour(x = 1:24, y = 1:12, z = t(corlist_dsci_mean[[i]]), add = TRUE, labcex = 1, levels = seq(from = -1, to = 1, length = 11))
                 })
  dev.off()
  
  # streamflow mean ~ SPI
  jpeg(paste("./Climate Sensitivity/Climate sensitivity plots/Streamflow_SPI_correlation_TimeVarying_", "site", i, "_mean.jpg", sep = ""), height = 6, width = 7, units = "in", res = 500)
  filled.contour(x = 1:24, y = 1:12, z = t(corlist_spi_mean[[i]]), 
                 levels = seq(from = -1, to = 1, length = n+1), col = hcl.colors(n, "PRGn"),
                 plot.title = title(main = sites[i], 
                                    xlab = "SPI - accumulation time scale (months)", 
                                    ylab = "Month"),
                 plot.axes = { 
                   axis(1, at = seq(from = 1, to = 23, by = 2))
                   axis(2, at = 1:12, labels = c("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D")) 
                   contour(x = 1:24, y = 1:12, z = t(corlist_spi_mean[[i]]), add = TRUE, labcex = 1, levels = seq(from = -1, to = 1, length = 11))
                 })
  dev.off()
  
  # streamflow minimum ~ DSCI
  jpeg(paste("./Climate Sensitivity/Climate sensitivity plots/Streamflow_DSCI_correlation_TimeVarying_", "site", i, "_min.jpg", sep = ""), height = 6, width = 7, units = "in", res = 500)
  filled.contour(x = 1:24, y = 1:12, z = t(corlist_dsci_min[[i]]), 
                 levels = seq(from = -1, to = 1, length = n+1), col = hcl.colors(n, "PRGn"),
                 plot.title = title(main = sites[i], 
                                    xlab = "DSCI - accumulation time scale (months)", 
                                    ylab = "Month"),
                 plot.axes = { 
                   axis(1, at = seq(from = 1, to = 23, by = 2))
                   axis(2, at = 1:12, labels = c("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D")) 
                   contour(x = 1:24, y = 1:12, z = t(corlist_dsci_min[[i]]), add = TRUE, labcex = 1, levels = seq(from = -1, to = 1, length = 11))
                 })
  dev.off()
  
  # streamflow minimum ~ SPI
  jpeg(paste("./Climate Sensitivity/Climate sensitivity plots/Streamflow_SPI_correlation_TimeVarying_", "site", i, "_min.jpg", sep = ""), height = 6, width = 7, units = "in", res = 500)
  filled.contour(x = 1:24, y = 1:12, z = t(corlist_spi_min[[i]]), 
                 levels = seq(from = -1, to = 1, length = n+1), col = hcl.colors(n, "PRGn"),
                 plot.title = title(main = sites[i], 
                                    xlab = "SPI - accumulation time scale (months)", 
                                    ylab = "Month"),
                 plot.axes = { 
                   axis(1, at = seq(from = 1, to = 23, by = 2))
                   axis(2, at = 1:12, labels = c("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D")) 
                   contour(x = 1:24, y = 1:12, z = t(corlist_spi_min[[i]]), add = TRUE, labcex = 1, levels = seq(from = -1, to = 1, length = 11))
                 })
  dev.off()
}

# plot raw data
plot(meanQ ~ spi_9, tt %>% filter(site_name == "Big Creek NWIS", Month == 10))
plot(z_flow_mean_monthly ~ spi_7, dat3 %>% filter(site_name == "Donner Blitzen River nr Frenchglen NWIS", month == 6))



filled.contour(x = 1:24, y = 1:12, z = t(mylist_dsci_slope[[1]]), 
                levels = seq(from = -1, to = 1, length = 50), 
               col = hcl.colors(50, "PRGn"),
                 plot.title = title(main = sites[i], 
                                    xlab = "DSCI - accumulation time scale (months)", 
                                    ylab = "Month"),
                 plot.axes = { 
                   axis(1, at = seq(from = 1, to = 23, by = 2))
                   axis(2, at = 1:12, labels = c("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D")) 
                   contour(x = 1:24, y = 1:12, z = t(mylist_dsci_slope[[i]]), add = TRUE, labcex = 1, levels = seq(from = -1, to = 1, length = 11))
                 })


filled.contour(x = 1:24, y = 1:12, z = t(mylist_spi_pval[[1]]), 
                levels = seq(from = 0, to = 1, length = 100), 
               col = hcl.colors(100, "Blues"))

filled.contour(x = 1:24, y = 1:12, z = t(mylist_spi_slope[[1]]), 
                levels = seq(from = -1, to = 1, length = 100), 
               col = hcl.colors(100, "PRGn"))